﻿'Digite o NameSpace: Babok

<Serializable()> _
Public Class ItemPriorizado
    Inherits BaseDominio

    Private _prioridade As Integer
    Public Overridable Property Prioridade() As Integer
        Get
            Return _prioridade
        End Get
        Set(ByVal value As Integer)
            _prioridade = value
        End Set
    End Property

    Private _complexidade As Integer
    Public Overridable Property Complexidade() As Integer
        Get
            Return _complexidade
        End Get
        Set(ByVal value As Integer)
            _complexidade = value
        End Set
    End Property

    Private _pontos As Integer
    Public Overridable Property Pontos() As Integer
        Get
            Return _pontos
        End Get
        Set(ByVal value As Integer)
            _pontos = value
        End Set
    End Property

    Private _itemBackLog As ItemBackLog
    Public Overridable Property ItemBackLog() As ItemBackLog
        Get
            Return _itemBackLog
        End Get
        Set(ByVal value As ItemBackLog)
            _itemBackLog = value
        End Set
    End Property

    Private _status As StatusItemPriorizado
    Public Overridable Property Status() As StatusItemPriorizado
        Get
            Return _status
        End Get
        Set(ByVal value As StatusItemPriorizado)
            _status = value
        End Set
    End Property

    Private _backlog As Backlog
    Public Overridable Property Backlog() As Backlog
        Get
            Return _backlog
        End Get
        Set(ByVal value As Backlog)
            _backlog = value
        End Set
    End Property

    Private _dataInicio As Nullable(Of DateTime)
    Public Overridable Property DataInicio() As Nullable(Of DateTime)
        Get
            Return _dataInicio
        End Get
        Set(ByVal value As Nullable(Of DateTime))
            _dataInicio = value
        End Set
    End Property

    Private _dataFim As Nullable(Of DateTime)
    Public Overridable Property DataFim() As Nullable(Of DateTime)
        Get
            Return _dataFim
        End Get
        Set(ByVal value As Nullable(Of DateTime))
            _dataFim = value
        End Set
    End Property



#Region "Negocio"

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal _prioridade As Integer, ByRef _itemBackLog As ItemBackLog)
        MyBase.New()
        Me._itemBackLog = _itemBackLog
        Me._prioridade = _prioridade
    End Sub

    Public Overridable Function Buscar(ByVal _id As Long) As ItemPriorizado
        Return MyBase.ItemPriorizadoDao.Buscar(_id)
    End Function

    Public Overridable Sub IniciarItem()
        Me._dataInicio = Now
        Me.ItemPriorizadoDao.Alterar(Me)
    End Sub

    Public Overridable Sub FinalizarItem()
        Me._dataFim = Now
        Me.ItemPriorizadoDao.Alterar(Me)
    End Sub

    Public Overridable Sub AlterarPrioridade(ByVal _prioridade As Integer)
        Me.Prioridade = _prioridade
        MyBase.ItemPriorizadoDao.Alterar(Me)
    End Sub

    Public Overridable Sub Salvar()
        If Me.Prioridade = 0 Then Me.Prioridade = 999

        If Me.BackLog Is Nothing Then Throw New ItemPriorizadoException("É preciso informar o Backlog ao qual o Item Priorizado pertence")

        MyBase.ItemPriorizadoDao.Salvar(Me)
    End Sub

#End Region

End Class

